<?php
class Z1dvxephangsController extends AppController {

	var $name = 'Z1dvxephangs';
	var $helpers = array('Html', 'Form');

	function index() {
		$this->Z1dvxephang->recursive = 0;
		$this->set('z1dvxephangs', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Z1dvxephang.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('z1dvxephang', $this->Z1dvxephang->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Z1dvxephang->create();
			if ($this->Z1dvxephang->save($this->data)) {
				$this->Session->setFlash(__('The Z1dvxephang has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Z1dvxephang could not be saved. Please, try again.', true));
			}
		}
		$donvis = $this->Z1dvxephang->Donvi->find('list');
		$thoigians = $this->Z1dvxephang->Thoigian->find('list');
		$kehoaches = $this->Z1dvxephang->Kehoach->find('list');
		$this->set(compact('donvis', 'thoigians', 'kehoaches'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Z1dvxephang', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->Z1dvxephang->save($this->data)) {
				$this->Session->setFlash(__('The Z1dvxephang has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Z1dvxephang could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Z1dvxephang->read(null, $id);
		}
		$donvis = $this->Z1dvxephang->Donvi->find('list');
		$thoigians = $this->Z1dvxephang->Thoigian->find('list');
		$kehoaches = $this->Z1dvxephang->Kehoach->find('list');
		$this->set(compact('donvis','thoigians','kehoaches'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for Z1dvxephang', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Z1dvxephang->del($id)) {
			$this->Session->setFlash(__('Z1dvxephang deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>